<?php
namespace Admin\Controller;
use Think\Controller;
class SiteController extends Controller 
{
	public function lst()
	{
		$serch=I('post.');
        $model = D('Site');
        $data = $model->search();

        $this->assign(array(
            'data' => $data['data'],
            'page' => $data['page'],
            'count' => $data['count'],
        ));
        $this->display();
	}

	public function add()
    {
    	if(IS_POST)
        {
            $model = D('Admin/Site');
            if($model->create(I('post.'), 1))
            {
                if($id = $model->add())
                {
                    $this->success('添加成功！', U('lst?p='.I('get.p')));
                    exit;
                }
            }
            $this->error($model->getError());
        }
        // $this->setPageBtn('添加文章', '文章列表', U('lst?p='.I('get.p')));
        $this->display();
    }

	public function del(){
		$ids = I('ids');
        if(is_array($ids)){
            foreach ($ids as $key => $value) {
                $ids[$key] = (int)$value;
            }
            $where = array('id'=>array('in', $ids));
        }else{
            $ids = intval($ids);
            $where = array('id'=>array('eq', $ids));
        }
        
        if(M('Site')->where($where)->delete()){
            $result['code'] = 0;
        }
        $this->ajaxReturn($result);
	}
}














